#define _CRT_SECURE_NO_WARNINGS 

#include <stdio.h>

void exchange(int* arr1)
{
	int i = 0;
	int j = 0;
	int min = arr1[0], max = arr1[0];
	for (int a = 0; i < 10; i++)
	{
		if (arr1[a] < min)
		{
			min = arr1[a];
			i = a;
		}
		if (arr1[a] > max)
		{
			max = arr1[a];
			j = a;
		}
	}
	arr1[i] = max;
	arr1[j] = min;
	printf("%d ", arr1);
}
int main()
{
	int arr1[10];
	for (int b = 0; b < 10; b++)
	{
		scanf("%d", &arr1[b]);
	}
	exchange(arr1);
	return 0;
}
